import request from "@/utils/request.js"
const state = {
	homeImageList: [],
	homeMoreList: []
}
const mutations = {
	SET_HOMEIMAGELIST(state, homeImageList) {
		state.homeImageList = homeImageList
	},
	SET_HOMEMORELIST(state, homeMoreList) {
		state.homeMoreList = state.homeMoreList.concat(homeMoreList)
	}
}
const actions = {
	
	async getHomeImageList({commit}) {
		let res = await request("mobile/new/home")
		commit("SET_HOMEIMAGELIST", res.data)
	},
	
	async getHomeMoreList({commit},{page,pageSize}){
		console.log(page)
		console.log(pageSize)
		let res = await request(`mobile/waterfall?page=${page}&pageSize=${pageSize}`)
		commit("SET_HOMEMORELIST",res.data.skuInfo)
		// console.log(res.data.skuInfo)
	}
}
const getters = {
	alwayImg(state) {
		return state.homeImageList.filter((item, index) => {
			return index > 0
		})
	}
}

export default {
	namespaced: true,
	state,
	mutations,
	actions,
	getters
}
